package com.luban.springboot9.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.luban.springboot9.pojo.User;
import com.luban.springboot9.service.UserService;


@RestController
public class UserController {
	
	@Autowired
	private UserService userService;
	
	/**
	 * 新增用户
	 */
	@RequestMapping(value="/addUser")
	public String addUser(User user) {
		userService.insertSelective(user);
		return "ok";
	}
	
	/**
	 * 查询某个用户
	 */
	@RequestMapping(value="/findUserById")
	public User userList(Integer id) {
		return userService.selectByPrimaryKey(id);
	}
	
	/**
	 * 修改用户
	 */
	@RequestMapping(value="/updateUser")
	public String updateUser(User user) {
		userService.updateByPrimaryKeySelective(user);
		return "ok";
	}
	/**
	 * 删除用户
	 */
	@RequestMapping(value="/deleteUser")
	public String deleteeUser(Integer id) {
		userService.deleteByPrimaryKey(id);
		return "ok";
	}

}
